"""
主题相关的模块
"""
import  requests
def topic_index(page=1,tab="ask",limit=20,mdrender="true"):
    """
    主题首页
    :return:
    """
    url = "http://47.100.175.62:3000/api/v1/topics"
    get_data = {
        "page":page,
        "tab":tab,
        "limit":limit,
        "mdrender":mdrender
    }
    return requests.get(url,params=get_data)
def create_topic(token="",title="",tab="",content=""):
    """
    :return:
    """
    url ="http://47.100.175.62:3000/api/v1/topics"
    postdata = {
        "accesstoken":token,
        "title":title,
        "tab":tab,
        "content":content
    }
    return requests.post(url,data=postdata)
def topic_detail(id,mdrender="ture",accesstoken=None):
    """
    主题详情
    :return:
    """
    url = f"http://47.100.175.62:3000/api/v1/topic/{id}"
    getdata = {}
    if accesstoken == None:
        getdata = {
            "mderender":mdrender
        }
    else:
        getdata = {
            "mdrender":mdrender,
            "accesstoken":accesstoken
        }
    return requests.get(url,params=getdata)